const express = require('express');
      router = express.Router();
      mySql = require('../db/index');

let send = (res,data,code,message) =>{
    // res为200的时候初始化数据
    res.status(200).json({data,code,message})
}

router.post('/index',(req,res) => {
    let username = req.body.username
    let password = req.body.password
    mySql.getMysql('SELECT 1 + 1 AS solution').then((data)=>{
        send(res,{username:username},0,'请求成功')
    }).catch((err)=>{
        send(res,{
            username:username,
            password:password,
        },0,err.code)
    })
})

module.exports = router